<html>
<head><meta charset="utf-8"><title>inlining/constifying all &quot;fn provide&quot; · t-compiler/performance · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/index.html">t-compiler/performance</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html">inlining/constifying all &quot;fn provide&quot;</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203490923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203490923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203490923">(Jul 10 2020 at 10:20)</a>:</h4>
<p>I want to try <code>#[inline(always)]</code> on <code>fn provide</code> functions and see if that has any perf effects</p>



<a name="203491087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203491087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203491087">(Jul 10 2020 at 10:22)</a>:</h4>
<p>(noting it down in case I forget)</p>



<a name="203623446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203623446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203623446">(Jul 12 2020 at 02:15)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> so the result is that:</p>
<div class="codehilite"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">default_type_of</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">for</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="w"> </span><span class="k">fn</span><span class="p">(</span><span class="n">TyCtxt</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">DefId</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Ty</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">providers</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Providers</span>::<span class="n">default</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">rustc_typeck</span>::<span class="n">provide</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">providers</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">providers</span><span class="p">.</span><span class="n">type_of</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>optimizes down to:</p>
<div class="codehilite"><pre><span></span><code>  <span class="k">ret</span> <span class="nv">%&quot;rustc_middle::ty::TyS&quot;</span><span class="p">*</span> <span class="p">(</span><span class="k">i64</span><span class="p">*,</span> <span class="k">i32</span><span class="p">,</span> <span class="k">i32</span><span class="p">)*</span> <span class="vg">@_ZN12rustc_typeck7collect7type_of7type_of17h576de94756ddadc8E</span>
</code></pre></div>



<a name="203623448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203623448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203623448">(Jul 12 2020 at 02:15)</a>:</h4>
<p>however I just realized that I can do much better: make all <code>fn provide</code> be <code>const fn</code></p>



<a name="203623565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203623565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203623565">(Jul 12 2020 at 02:19)</a>:</h4>
<p>much stronger guarantees... in fact, a struct of functions is very close to a <code>trait</code> vtable :P</p>



<a name="203624357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624357">(Jul 12 2020 at 02:49)</a>:</h4>
<p>Ooh <code>provide</code> could be a trait where every function has a default implementation!</p>



<a name="203624400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624400">(Jul 12 2020 at 02:50)</a>:</h4>
<p>And then we don't need to hack around with thread locals, just override the functions we care about :D</p>



<a name="203624401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624401">(Jul 12 2020 at 02:50)</a>:</h4>
<p>not really, the problem is is combining them</p>



<a name="203624405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624405">(Jul 12 2020 at 02:50)</a>:</h4>
<p>you won't need thread-locals once I finish this PR</p>



<a name="203624508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624508">(Jul 12 2020 at 02:55)</a>:</h4>
<blockquote>
<p>not really, the problem is is combining them</p>
</blockquote>
<p>Not sure I follow but I'll wait to see what your PR is doing</p>



<a name="203624510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624510">(Jul 12 2020 at 02:55)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> specifically you don't want <code>rustc_interface</code> to have to refer to every single provider ever</p>



<a name="203624512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624512">(Jul 12 2020 at 02:55)</a>:</h4>
<p>the current system works because each <code>fn provide</code> can write whichever subset of the fields it wants to</p>



<a name="203624552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624552">(Jul 12 2020 at 02:56)</a>:</h4>
<p>Right</p>



<a name="203624554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624554">(Jul 12 2020 at 02:56)</a>:</h4>
<p>There's a default <code>provide</code> and then you can override individual queries</p>



<a name="203624555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624555">(Jul 12 2020 at 02:56)</a>:</h4>
<p>Which sounds a lot like a trait to me</p>



<a name="203624558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624558">(Jul 12 2020 at 02:57)</a>:</h4>
<p>there's over 50 different <code>fn provide</code></p>



<a name="203624561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624561">(Jul 12 2020 at 02:57)</a>:</h4>
<p>and like 200 queries</p>



<a name="203624565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624565">(Jul 12 2020 at 02:57)</a>:</h4>
<p>Sure, each trait implementation only has to override the queries it cares about</p>



<a name="203624567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624567">(Jul 12 2020 at 02:57)</a>:</h4>
<p>And the rest stay as the default</p>



<a name="203624568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624568">(Jul 12 2020 at 02:57)</a>:</h4>
<p>but you can't combine traits</p>



<a name="203624607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624607">(Jul 12 2020 at 02:58)</a>:</h4>
<p>if you have one trait with 50 impls, how do you combine those (presumably implemented on 50 <code>struct Foo;</code>) into one impl?</p>



<a name="203624613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624613">(Jul 12 2020 at 02:59)</a>:</h4>
<p>(I actually came up with 1 or 2 ways of doing it but it's an absolute mess and/or might require specialization)</p>



<a name="203624659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624659">(Jul 12 2020 at 03:00)</a>:</h4>
<p>you're saying there's no default that makes sense? I'm not sure I follow what you mean by 'combine those into one impl'</p>



<a name="203624661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624661">(Jul 12 2020 at 03:00)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> this is the kind of thing I mean <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_interface/passes.rs#L723-L740">https://github.com/rust-lang/rust/blob/master/src/librustc_interface/passes.rs#L723-L740</a></p>



<a name="203624665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624665">(Jul 12 2020 at 03:00)</a>:</h4>
<p>hmm</p>



<a name="203624668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624668">(Jul 12 2020 at 03:00)</a>:</h4>
<p>each call can do arbitrary mutations on the <code>Providers</code>, but you can't "mutate" a trait impl</p>



<a name="203624673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624673">(Jul 12 2020 at 03:01)</a>:</h4>
<p>overriding queries in custom drivers isn't as interesting, because it's a small finite number, there's a few ways in which you can do it but you could just as well still mutate a struct of <code>fn</code> pointers</p>



<a name="203624675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624675">(Jul 12 2020 at 03:01)</a>:</h4>
<p>How about <code>trait Provide: Analysis + ProcMacroDecls + Plugin ...</code>? It's super ugly but you could override any specific inner trait</p>



<a name="203624676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624676">(Jul 12 2020 at 03:01)</a>:</h4>
<p>I guess at that point it's not really better than the current situation</p>



<a name="203624677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624677">(Jul 12 2020 at 03:01)</a>:</h4>
<p>alright but that requires splitting the queries into traits</p>



<a name="203624715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624715">(Jul 12 2020 at 03:02)</a>:</h4>
<p>and consider the fact that <code>rustc_metadata</code> overrides a bunch of queries that all over the place</p>



<a name="203624718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624718">(Jul 12 2020 at 03:02)</a>:</h4>
<p>IMO splitting the queries makes sense but only in terms of the data types they refer to and what code should be allowed to <em>call</em> them</p>



<a name="203624724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624724">(Jul 12 2020 at 03:02)</a>:</h4>
<p>not where they're implemented</p>



<a name="203624730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624730">(Jul 12 2020 at 03:03)</a>:</h4>
<p>(so you could have crates that only know about a subset of the queries, even if they might be implemented somewhere else entirely etc.)</p>



<a name="203624736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624736">(Jul 12 2020 at 03:03)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> anyway the one way which I believe can work is a trick that I first came up with for ObjectiveC modelling, I believe</p>



<a name="203624739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624739">(Jul 12 2020 at 03:03)</a>:</h4>
<p>so you know how you can use <code>Deref</code> to emulate single inheritance?</p>



<a name="203624779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624779">(Jul 12 2020 at 03:04)</a>:</h4>
<p>you can emulate multiple inheritance with it too, you just have to be sneaky :P</p>



<a name="203624795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624795">(Jul 12 2020 at 03:05)</a>:</h4>
<p>you can represent <code>A + B + C</code> as <code>A&lt;B&lt;C&lt;()&gt;&gt;&gt;</code>. so you could imagine <code>A&lt;B&lt;C&lt;()&gt;&gt;&gt;</code> representing "an object that implements interfaces A, B and C"</p>



<a name="203624836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624836">(Jul 12 2020 at 03:06)</a>:</h4>
<p>and then,</p>



<a name="203624838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624838">(Jul 12 2020 at 03:06)</a>:</h4>
<p>wait, you can do it even cleaner than that heh</p>



<a name="203624847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624847">(Jul 12 2020 at 03:07)</a>:</h4>
<p>okay let's keep it simple: each of those wrappers derefs to what's inside. so a method on any of them will be callable on the whole thing</p>



<a name="203624852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624852">(Jul 12 2020 at 03:07)</a>:</h4>
<p>anyway what I realized just saying that is that <code>Foo&lt;(A, (B, (C, ())))&gt;</code> can also work, if you admit either some associated type nonsense, or just unsafe code in the <code>Deref</code> impl</p>



<a name="203624854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624854">(Jul 12 2020 at 03:07)</a>:</h4>
<p>I'm imagining like 50 levels of types lol</p>



<a name="203624895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624895">(Jul 12 2020 at 03:08)</a>:</h4>
<p>since you can have that type derefing to <code>Foo&lt;(B, (C, ()))&gt;</code> or even removing <code>C</code> from the other end (but that'd be harder)</p>



<a name="203624897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624897">(Jul 12 2020 at 03:08)</a>:</h4>
<p>and instead of tuples you can use the hlist crate etc.</p>



<a name="203624908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624908">(Jul 12 2020 at 03:09)</a>:</h4>
<p>sounds like you need to make a crate for multiple inheritance :P</p>



<a name="203624909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624909">(Jul 12 2020 at 03:09)</a>:</h4>
<p>anyway, something like that could be used for queries where by default it just goes to the next level down, but you can override it</p>



<a name="203624911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624911">(Jul 12 2020 at 03:09)</a>:</h4>
<p>might even be doable with just a trait, no macros (other than to generate the trait in the first place)</p>



<a name="203624950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624950">(Jul 12 2020 at 03:10)</a>:</h4>
<p>anyway it's kind of a mess</p>



<a name="203624952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624952">(Jul 12 2020 at 03:10)</a>:</h4>
<p>it looks like hlist does something like this already actually <a href="https://docs.rs/hlist/0.1.2/hlist/trait.Find.html">https://docs.rs/hlist/0.1.2/hlist/trait.Find.html</a></p>



<a name="203624957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624957">(Jul 12 2020 at 03:10)</a>:</h4>
<p>you say <code>.get()</code> and the compiler performs deref arbitrarily many times</p>



<a name="203624958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624958">(Jul 12 2020 at 03:10)</a>:</h4>
<p><em>shudders</em></p>



<a name="203624961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624961">(Jul 12 2020 at 03:10)</a>:</h4>
<p>no this is not deref-based</p>



<a name="203624963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624963">(Jul 12 2020 at 03:10)</a>:</h4>
<p>the deref-based stuff allows you to customize method lookup</p>



<a name="203624970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624970">(Jul 12 2020 at 03:11)</a>:</h4>
<p>since the compiler will stop deref-ing when it finds something with that name</p>



<a name="203624971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624971">(Jul 12 2020 at 03:11)</a>:</h4>
<p>whereas here it's just using a trait to recurse</p>



<a name="203624973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203624973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203624973">(Jul 12 2020 at 03:11)</a>:</h4>
<p>lol @ <code>.push(...)</code>, that's cute</p>



<a name="203625012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203625012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203625012">(Jul 12 2020 at 03:12)</a>:</h4>
<p>anyway yeah, there are ways to do this but they're not simple, that's for sure</p>



<a name="203625183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203625183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203625183">(Jul 12 2020 at 03:18)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> and they're not guaranteed to optimize as well as CTFE.... unless we use associated consts with <code>fn</code> pointer types lol</p>



<a name="203625190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203625190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203625190">(Jul 12 2020 at 03:18)</a>:</h4>
<p>which is very much a struct</p>



<a name="203625242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203625242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203625242">(Jul 12 2020 at 03:20)</a>:</h4>
<p>either way it might still require specialization or a macro to have defaults that vary between impls</p>



<a name="203661914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203661914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203661914">(Jul 12 2020 at 21:26)</a>:</h4>
<p>(just realized I can edit the topic by pressing the pencil button next to the topic name, not messing with messages)</p>



<a name="203661925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203661925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203661925">(Jul 12 2020 at 21:27)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> so yeah I have <code>const DEFAULT_PROVIDERS: Providers</code> now :)</p>



<a name="203661992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203661992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203661992">(Jul 12 2020 at 21:28)</a>:</h4>
<p>okay that's really weird, <code>const fn</code> doesn't behave as if it's <code>#[inline]</code></p>



<a name="203662001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203662001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203662001">(Jul 12 2020 at 21:28)</a>:</h4>
<p>even though it could be codegen'd across crates</p>



<a name="203662009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203662009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203662009">(Jul 12 2020 at 21:28)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="124288">@oli</span>, is this intentional?</p>



<a name="203662281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203662281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203662281">(Jul 12 2020 at 21:35)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> <code>rustc_interface::DEFAULT_PROVIDERS.type_of</code> optimizes to a constant <code>fn</code> pointer :)</p>



<a name="203662334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203662334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203662334">(Jul 12 2020 at 21:36)</a>:</h4>
<p>and a <code>static</code> requires no optimization to get there :D</p>



<a name="203662369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203662369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203662369">(Jul 12 2020 at 21:37)</a>:</h4>
<p>or a function using a <code>const</code> that was initialized from <code>DEFAULT_PROVIDERS.type_of</code></p>



<a name="203662408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203662408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203662408">(Jul 12 2020 at 21:38)</a>:</h4>
<p>I'll rename those to have QUERY in their name I think</p>



<a name="203663038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203663038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203663038">(Jul 12 2020 at 21:56)</a>:</h4>
<p>That sounds awesome!</p>



<a name="203663611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203663611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203663611">(Jul 12 2020 at 22:12)</a>:</h4>
<p>yeah I just need to write a PR description now</p>



<a name="203669693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203669693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203669693">(Jul 13 2020 at 01:08)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> in case you didn't see it: <a href="https://github.com/rust-lang/rust/pull/74283">https://github.com/rust-lang/rust/pull/74283</a></p>



<a name="203669698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203669698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203669698">(Jul 13 2020 at 01:08)</a>:</h4>
<p>looks much nicer :)</p>



<a name="203669699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203669699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203669699">(Jul 13 2020 at 01:08)</a>:</h4>
<p>also I'm getting a far more scary stage1 rustc failure locally, where it looks like the wrong providers are used. but it's different from the CI failure</p>



<a name="203669705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203669705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203669705">(Jul 13 2020 at 01:09)</a>:</h4>
<p>I might just need to nuke stage1*</p>



<a name="203669775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203669775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203669775">(Jul 13 2020 at 01:11)</a>:</h4>
<p>yeah, must've been some stale rlibs</p>



<a name="203684824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203684824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203684824">(Jul 13 2020 at 07:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22/near/203662009">said</a>:</p>
<blockquote>
<p>cc <span class="user-mention silent" data-user-id="124288">oli</span>, is this intentional?</p>
</blockquote>
<p>no, I would have thought this would work since I thought the part that checks whether you can cross crate inline is <code>is_mir_availabe</code></p>



<a name="203684965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203684965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203684965">(Jul 13 2020 at 07:28)</a>:</h4>
<p>heh</p>



<a name="203684974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203684974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203684974">(Jul 13 2020 at 07:29)</a>:</h4>
<p>I think there's also a predicate for "was this codegen'd upstream"</p>



<a name="203701639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203701639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203701639">(Jul 13 2020 at 11:04)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I feel like something is pulling a prank on me <a href="https://github.com/rust-lang/rust/pull/74283#issuecomment-657486053">https://github.com/rust-lang/rust/pull/74283#issuecomment-657486053</a></p>



<a name="203701654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203701654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203701654">(Jul 13 2020 at 11:04)</a>:</h4>
<p>surely moving something from runtime to CTFE should at least not change the performance</p>



<a name="203702088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702088">(Jul 13 2020 at 11:10)</a>:</h4>
<p>I think you lost all your perf in metadata_register_crate</p>



<a name="203702112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702112">(Jul 13 2020 at 11:10)</a>:</h4>
<p>only noticable for super super fast compiler runs (less than 10ms)</p>



<a name="203702134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702134">(Jul 13 2020 at 11:11)</a>:</h4>
<p>huh that does track. but why?</p>



<a name="203702161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702161">(Jul 13 2020 at 11:11)</a>:</h4>
<p>copying large things instead of just assigning a few fields?</p>



<a name="203702168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702168">(Jul 13 2020 at 11:11)</a>:</h4>
<p>it's not like the copies could've been removed before</p>



<a name="203702220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702220">(Jul 13 2020 at 11:12)</a>:</h4>
<p>it's all across non-<code>#[inline]</code> non-generic call boundaries</p>



<a name="203702237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702237">(Jul 13 2020 at 11:12)</a>:</h4>
<p>and, like, by the time a crate is... wait</p>



<a name="203702241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702241">(Jul 13 2020 at 11:12)</a>:</h4>
<p><span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="203702244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702244">(Jul 13 2020 at 11:12)</a>:</h4>
<p>crates are already known when creating the <code>TyCtxt</code></p>



<a name="203702378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702378">(Jul 13 2020 at 11:14)</a>:</h4>
<p>just do a mir dump of before/after I guess?</p>



<a name="203702433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702433">(Jul 13 2020 at 11:15)</a>:</h4>
<p>you're joking, right :P?</p>



<a name="203702451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702451">(Jul 13 2020 at 11:15)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> <code>TyCtxt::create_global_ctxt</code> is not <code>#[inline]</code> nor generic</p>



<a name="203702526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702526">(Jul 13 2020 at 11:16)</a>:</h4>
<p>llvm lto doesn't care about that though, but even without inlining, I think it can be just within one of the provider functions</p>



<a name="203702590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702590">(Jul 13 2020 at 11:17)</a>:</h4>
<p>so there's no way its replicating of the providers to per-crate (which might be a waste of time <em>shrug</em>) would be impacted by whatever is on the other side of the call</p>



<a name="203702598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702598">(Jul 13 2020 at 11:17)</a>:</h4>
<p>but we don't run LTO, do we?</p>



<a name="203702622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702622">(Jul 13 2020 at 11:17)</a>:</h4>
<p>and ThinLTO is between the CGUs of one crate</p>



<a name="203702630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702630">(Jul 13 2020 at 11:17)</a>:</h4>
<p>am I missing something?</p>



<a name="203702706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702706">(Jul 13 2020 at 11:18)</a>:</h4>
<p>lol <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_middle/ty/context.rs#L1084-L1085">https://github.com/rust-lang/rust/blob/master/src/librustc_middle/ty/context.rs#L1084-L1085</a></p>



<a name="203702722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702722">(Jul 13 2020 at 11:18)</a>:</h4>
<p>I just noticed how inefficient that is</p>



<a name="203702725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702725">(Jul 13 2020 at 11:18)</a>:</h4>
<p>that's what I mean, even without cross crate inlining, the provider functions themselves will now be copying around large things</p>



<a name="203702751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702751">(Jul 13 2020 at 11:18)</a>:</h4>
<p>why would you say that?</p>



<a name="203702774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702774">(Jul 13 2020 at 11:19)</a>:</h4>
<p>there were no optimizations before</p>



<a name="203702792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702792">(Jul 13 2020 at 11:19)</a>:</h4>
<p>which is why I made this PR in the first place</p>



<a name="203702807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702807">(Jul 13 2020 at 11:19)</a>:</h4>
<p>everything was just bulk copies and field writes</p>



<a name="203702818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702818">(Jul 13 2020 at 11:19)</a>:</h4>
<p>completely isolated between crates</p>



<a name="203702881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702881">(Jul 13 2020 at 11:20)</a>:</h4>
<p>oh... wait, I thought you were creating loads and loads of constants</p>



<a name="203702886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702886">(Jul 13 2020 at 11:20)</a>:</h4>
<p>I removed all the overhead of <code>fn provide</code></p>



<a name="203702893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702893">(Jul 13 2020 at 11:20)</a>:</h4>
<p>but it's just one constant at the end</p>



<a name="203702899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702899">(Jul 13 2020 at 11:20)</a>:</h4>
<p>ofc</p>



<a name="203702910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702910">(Jul 13 2020 at 11:20)</a>:</h4>
<p>it's the same thing as before, just CTFE instead of at runtime</p>



<a name="203702921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702921">(Jul 13 2020 at 11:20)</a>:</h4>
<p>so it should just get copied from <code>.rodata</code> or w/e onto the stack</p>



<a name="203702968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702968">(Jul 13 2020 at 11:21)</a>:</h4>
<p>ah yes, so the difference is indeed that we now copy the entire thing from rodata to the stack in <a href="https://github.com/rust-lang/rust/pull/74283/files#diff-24c5c945888bb0d041e769bfb852de6cR802">https://github.com/rust-lang/rust/pull/74283/files#diff-24c5c945888bb0d041e769bfb852de6cR802</a></p>



<a name="203702974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702974">(Jul 13 2020 at 11:21)</a>:</h4>
<p>instead of assigning each field on its own</p>



<a name="203702978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203702978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203702978">(Jul 13 2020 at 11:21)</a>:</h4>
<p>whereas before we were probably doing ~50 copies</p>



<a name="203703013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703013">(Jul 13 2020 at 11:22)</a>:</h4>
<p>although it's possible LLVM is smart enough to remove some of them from FRU, idk</p>



<a name="203703044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703044">(Jul 13 2020 at 11:22)</a>:</h4>
<p>I could check I guess?</p>



<a name="203703054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703054">(Jul 13 2020 at 11:22)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/query/struct.Providers.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/query/struct.Providers.html</a> is huuge</p>



<a name="203703058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703058">(Jul 13 2020 at 11:22)</a>:</h4>
<p>yes</p>



<a name="203703063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703063">(Jul 13 2020 at 11:22)</a>:</h4>
<p>I <em>removed</em> copies</p>



<a name="203703073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703073">(Jul 13 2020 at 11:22)</a>:</h4>
<p>none of the field writes you're thinking of were getting inlined</p>



<a name="203703114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703114">(Jul 13 2020 at 11:23)</a>:</h4>
<p>idk what you mean, all the provide functions take mutable references</p>



<a name="203703119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703119">(Jul 13 2020 at 11:23)</a>:</h4>
<p>even with 0 copies (which I doubt is possible), there would be more  field writes than there are fields copied after my PR</p>



<a name="203703132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703132">(Jul 13 2020 at 11:23)</a>:</h4>
<p>yes and then do <code>*providers = Providers { foo, ..*providers };</code></p>



<a name="203703143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703143">(Jul 13 2020 at 11:24)</a>:</h4>
<p>I'm trusting llvm there to get rid of that</p>



<a name="203703181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703181">(Jul 13 2020 at 11:24)</a>:</h4>
<p>which is the main reason <code>Providers</code> is <code>Copy</code></p>



<a name="203703196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703196">(Jul 13 2020 at 11:24)</a>:</h4>
<p>I don't, so we should tie-breake by checking :P</p>



<a name="203703220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703220">(Jul 13 2020 at 11:24)</a>:</h4>
<p>why do we even do that and not just assign to fields?</p>



<a name="203703228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703228">(Jul 13 2020 at 11:24)</a>:</h4>
<p>ergonomics lol</p>



<a name="203703239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703239">(Jul 13 2020 at 11:24)</a>:</h4>
<p>oh, because names of functions fit the names of fields</p>



<a name="203703245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703245">(Jul 13 2020 at 11:25)</a>:</h4>
<p>yeah</p>



<a name="203703363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703363">(Jul 13 2020 at 11:26)</a>:</h4>
<p>okay huh LLVM does optimize that</p>



<a name="203703389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703389">(Jul 13 2020 at 11:26)</a>:</h4>
<p>do we not generate a memcpy at all I wonder?</p>



<a name="203703419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703419">(Jul 13 2020 at 11:27)</a>:</h4>
<p>haha</p>



<a name="203703425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703425">(Jul 13 2020 at 11:27)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> yeah it's not LLVM lmao</p>



<a name="203703450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703450">(Jul 13 2020 at 11:27)</a>:</h4>
<p>let me try to force us to generate a <code>memcpy</code>, I again doubt that LLVM can optimize anything involving indirection</p>



<a name="203703466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703466">(Jul 13 2020 at 11:28)</a>:</h4>
<p>wait. I literally have a field assignment</p>



<a name="203703519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703519">(Jul 13 2020 at 11:28)</a>:</h4>
<p>/me should not do this sort of thing this tired</p>



<a name="203703559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703559">(Jul 13 2020 at 11:29)</a>:</h4>
<p>okay LLVM does optimize it :/</p>



<a name="203703588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703588">(Jul 13 2020 at 11:29)</a>:</h4>
<p>I wonder if it's the dereferenceable or the unsynchronized accesses</p>



<a name="203703642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703642">(Jul 13 2020 at 11:30)</a>:</h4>
<p>LLVM can barely optimize <code>memcpy</code>s between two <code>alloca</code>s</p>



<a name="203703651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703651">(Jul 13 2020 at 11:30)</a>:</h4>
<p><span aria-label="frown" class="emoji emoji-1f641" role="img" title="frown">:frown:</span></p>



<a name="203703658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703658">(Jul 13 2020 at 11:30)</a>:</h4>
<p>idk, this is out of my territory</p>



<a name="203703670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703670">(Jul 13 2020 at 11:30)</a>:</h4>
<p>anyway so now that we've settled that you were right about LLVM optimizations</p>



<a name="203703701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203703701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203703701">(Jul 13 2020 at 11:31)</a>:</h4>
<p>why would writing all fields effectively twice (once for the default and once again when installing the provider) be faster than one <code>memcpy</code>?</p>



<a name="203794082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203794082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203794082">(Jul 14 2020 at 02:46)</a>:</h4>
<p><em>discussion (on the cursed behavior I managed to trigger) continues in <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen'd.20downstream">in another topic</a></em></p>



<a name="203902893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203902893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203902893">(Jul 14 2020 at 23:59)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> at some point I remember you mentioning having a single <code>lazy_static</code> in rustc_interface so that each crate that wants to use the defaults doesn't need their own. Is that still planned? Writing some docs around queries for rustc_dev_guide now, if things are still up in the air I can wait for this section though</p>



<a name="203902916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203902916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203902916">(Jul 14 2020 at 23:59)</a>:</h4>
<p>do you want to make a PR for it?</p>



<a name="203902959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203902959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203902959">(Jul 15 2020 at 00:00)</a>:</h4>
<p>if not I will</p>



<a name="203902965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203902965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203902965">(Jul 15 2020 at 00:00)</a>:</h4>
<p>I can, where would it go?</p>



<a name="203902982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203902982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203902982">(Jul 15 2020 at 00:00)</a>:</h4>
<p>I'm done with the 3 PRs that were fallout from my experiment</p>



<a name="203903005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203903005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203903005">(Jul 15 2020 at 00:00)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> see the <code>const</code>s in my PR, you can do the same but with <code>lazy_static!</code></p>



<a name="203904794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203904794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203904794">(Jul 15 2020 at 00:27)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> <a href="https://github.com/rust-lang/rust/pull/74347">https://github.com/rust-lang/rust/pull/74347</a></p>



<a name="203904843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203904843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203904843">(Jul 15 2020 at 00:28)</a>:</h4>
<p>(the PR description isn't great but everything relevant is already in your PR, which I linked)</p>



<a name="203904878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203904878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203904878">(Jul 15 2020 at 00:28)</a>:</h4>
<p>lol @ using <code>Lazy</code></p>



<a name="203904909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203904909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203904909">(Jul 15 2020 at 00:28)</a>:</h4>
<p>what's wrong with lazy?</p>



<a name="203904921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203904921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203904921">(Jul 15 2020 at 00:29)</a>:</h4>
<p>I'm not used to seeing it, that's all</p>



<a name="203904925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203904925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203904925">(Jul 15 2020 at 00:29)</a>:</h4>
<p>over <code>lazy_static!</code></p>



<a name="203904932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203904932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203904932">(Jul 15 2020 at 00:29)</a>:</h4>
<p>funny enough rustc_interface used <code>once_cell</code> but not lazy_static at all</p>



<a name="203904939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203904939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203904939">(Jul 15 2020 at 00:29)</a>:</h4>
<p>maybe it switched recently</p>



<a name="203904958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203904958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203904958">(Jul 15 2020 at 00:29)</a>:</h4>
<p>personally I like it better just because it doesn't make me indent twice lol</p>



<a name="203997902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203997902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203997902">(Jul 15 2020 at 18:59)</a>:</h4>
<p>btw I'm outraged no one noticed my branch name</p>



<a name="203997930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/inlining/constifying%20all%20%22fn%20provide%22/near/203997930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22.html#203997930">(Jul 15 2020 at 18:59)</a>:</h4>
<p><code>ive-got-a-small-query-for-you</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>